/**
 * InterruptTest is a simple sketch to illustrate that the Photodiode is correctly wired
 * and that the value of r1 is such that you get a reasonable voltage change at the output.
 * This sketch uses interrupt 0 (attached to D2) as inout and looks for a rising edge. On
 * encountering a rising edge pin 8 is driven high for the time it takes for a loop to
 * execute 5000 times.
 */
/** pin that is driven high when interrupt routine is fired */
int pin = 8;
/** D2 refers to the digital pin associated with interrupt 0 */
int D2 = 0;

/**
 * Standard sketch setup function. Initialise outbound pins and attach flash function
 * on the interrupt defined by D2 on a rising edge.
 */
void setup()
{
  pinMode(pin, OUTPUT);
  attachInterrupt(D2, flash, RISING);
}

/**
 * Standard sketch loop function. Simply set the value of pin low.
 */
void loop()
{
  digitalWrite(pin, LOW);

}

/**
 * The flash function is invoked when the interrupt is fired. It sets the pin specified by
 * pin high for the time it takes to execute a for loop 5000 times.
 */
void flash()
{

  for(int i=0; i<5000; i++)
  {
  digitalWrite(pin,HIGH);      
  }
}
